<?php
class LinksController extends AppController {
	var $name = 'Links';

    public function manage () {
        if (!$this->_checkLogged('A')) {
            return;
        }

        if ($form = $this->params['form']) {
            foreach ($form as $k=>$v) {
                if (strpos($k, 'ame_')) {
                    $id = str_replace('name_', '', $k);
                    $data = array(
                        'Link' => array(
                            'id'   => $id,
                            'name' => $v,
                            'link' => $form['link_'.$id]
                        )
                    );
                    $this->Link->save($data);
                }
            }
            $this->Session->setFlash('<h4>'.__('All hyper links have been updated.',true).'</h4>', 'default', array('class'=>'boxSuccess'));
        }

        $data = $this->Link->find('all', array(
            'order' => array('Link.id')
        ));

        $this->pageTitle   = __('Manage Links',true);
        $this->set('data', $data);
    } // manage
} // LinksController
?>